home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume7 / image / part02 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  43.0 KB

  1. Subject:  v07i065:  Image manipulation routines in C++, Part02/05
  2. Newsgroups: mod.sources
  3. Approved: mirror!rs
  4.  
  5. Submitted by: David Sher <seismo!rochester!sher>
  6. Mod.sources: Volume 7, Issue 65
  7. Archive-name: image/Part02
  8.  
  9.  
  10. [  The Makefiles had ESCAPE and \r characters in their comment lines;
  11.    I changed them to their printable representation, the two-character
  12.    sequences ^[ and ^M, respectively.  Also, the file ascii2var/uu.test.var
  13.    had some non-ASCII characters in it; I used uuencode; the resultant
  14.    file is really ascii2var/test.var.  Also, I do not have C++ nor any
  15.    images, so I have not tested this package.  --r$  ]
  16.  
  17. #!/bin/sh
  18. # This is a shell archive.  Remove anything before this line,
  19. # then unpack it by saving it in a file and typing "sh file".
  20. # If all goes well, you will see the message "No problems found."
  21. # Wrapped by mirror!rs on Mon Nov 10 13:40:52 EST 1986
  22.  
  23. # Exit status; set to 1 on "wc" errors or if would overwrite.
  24. STATUS=0
  25. # Contents:  man/vartools.3 man/var2ascii.1 man/truncate.1
  26. #    man/scale.1 man/correlate.1 man/lowerbound.1 man/upperbound.1
  27. #    scale/main.c++ scale/makefile truncate/main.c++ truncate/makefile
  28. #    upperbound/main.c++ upperbound/makefile var2ascii/main.c++
  29. #    var2ascii/makefile varc++/archive.h++ varc++/bitio.h++
  30. #    varc++/char_image.h++ varc++/error.h++
  31.  
  32. echo x - man/vartools.3
  33. if test -f man/vartools.3 ; then
  34.     echo man/vartools.3 exists, putting output in $$man/vartools.3
  35.     OUT=$$man/vartools.3
  36.     STATUS=1
  37. else
  38.     OUT=man/vartools.3
  39. fi
  40. sed 's/^X//' > $OUT <<'@//E*O*F man/vartools.3//'
  41. X.TH VARTOOLS 3 8/25/86
  42. X.CM 1
  43. X.SH "NAME"
  44. Xvartools \- iff2var var2iff ascii2var var2ascii trunc scale correlate trunc2 scale2 correlate2
  45. X.SH "SYNOPSIS"
  46. X.nf
  47. XCompile with -lvartools -lvar -liff -lC (C)
  48. XCompile with -lvartools -lvar -liff (C++)
  49. X#include <vartools.h> (C)
  50. X#include <vartools.h++> (C++)
  51. X/*
  52. X    This routine gets information from an iff file and constructs
  53. X    a var file from it
  54. X    comments is a null terminated string that sets up the
  55. X    comments for the var file
  56. X*/
  57. Xvoid
  58. Xiff2var(FILE *iff_file, FILE *var_file, char *comments);
  59. X.sp
  60. X/*
  61. X    This routine gets information from a var file and constructs
  62. X    an iff file from it.
  63. X    This only works with graytone (integer) var files 
  64. X    To make a double var file into a graytone one use trunc
  65. X*/
  66. Xvoid
  67. Xvar2iff(FILE *var_file, FILE *iff_file);
  68. X.sp
  69. X/*
  70. X    This converts a file in ascii format to a double var file
  71. X    ascii format is 2 dimensions followed by an appropriate number
  72. X    of doubles followed by comments
  73. X    input is a file pointer to the input file
  74. X    output is a file pointer open for output
  75. X*/
  76. Xvoid
  77. Xascii2var(FILE *input , FILE *output);
  78. X.sp
  79. X/*
  80. X   This takes an initialized double image and outputs a file in ascii format
  81. X   described above
  82. X   input is an initialized image
  83. X   output is a file pointer open for output
  84. X   format is the format to output each number
  85. X*/
  86. Xvoid
  87. Xvar2ascii2(double_image& input , FILE *output , char *format );
  88. X.sp
  89. X/*
  90. X    This is a version of var2ascii that takes an input file rather
  91. X    than an initialized image
  92. X*/
  93. Xvoid
  94. Xvar2ascii(FILE *input, FILE *output , char *format);
  95. X.sp
  96. X/*
  97. X    Truncates an input image (takes floating point to long)
  98. X    needs a file to be output to
  99. X    but does not write to file
  100. X    instead returns the truncated image
  101. X*/
  102. Xlong_image&
  103. Xtrunc2( double_image& input , FILE *outfile );
  104. X.sp
  105. X/*
  106. X    Truncates a double image into a graytone (integer image)
  107. X    Takes two files and reads from one to write to the other
  108. X    comment is a comment to be placed on the image
  109. X*/
  110. Xvoid
  111. Xtrunc( FILE *infile , FILE *outfile, char *comment);
  112. X.sp
  113. X/*
  114. X    This takes an image as input and creates another
  115. X    It takes every pixel of the image and multiplies it by the
  116. X    scale and then adds to it the increment.
  117. X*/
  118. Xdouble_image&
  119. Xscale2(double scale, double increment, double_image& input, FILE *output_file);
  120. X.sp
  121. X/*
  122. X    This takes two files and takes one and puts 
  123. X    a scaled and incremented version into the other
  124. X    comment will be placed in the comment for the output image
  125. X*/
  126. Xvoid
  127. Xscale(double scale, double increment, FILE *input, FILE *output, char * comment);
  128. X.sp
  129. X/*
  130. X   this one takes 2 images and returns an image containing the 
  131. X   correlation of the input image with the template image
  132. X   it only returns values for the point where the template lies
  133. X   entirely within the input
  134. X*/
  135. Xdouble_image&
  136. Xcorrelate2(double_image& template, double_image& input, FILE *output_file);
  137. X.sp
  138. X/*
  139. X   this one takes 2 image files and returns an image file containing the 
  140. X   correlation of the input image with the template image
  141. X   it only returns values for the point where the template lies
  142. X   entirely within the input
  143. X*/
  144. Xvoid
  145. Xcorrelate(FILE *template_file, FILE *input_file, FILE *output_file, char *comment);
  146. X.sp
  147. X/*
  148. X    This code places an upper bound on the values of the pixels.
  149. X    If a pixel exceeds the bound it is set to the bound.
  150. X*/
  151. Xdouble_image&
  152. Xupper_bound2(double bound, double_image& input, FILE * output_file);
  153. X.sp
  154. X/*
  155. X    This code places an lower bound on the values of the pixels.
  156. X    If a pixel exceeds the bound it is set to the bound.
  157. X*/
  158. Xdouble_image&
  159. Xlower_bound2(double bound, double_image& input, FILE * output_file);
  160. X.sp
  161. X/*
  162. X    This code is like upper_bound2 but with files (for C)
  163. X*/
  164. Xvoid
  165. Xupper_bound(double bound, FILE * input_file, FILE * output_file, char *comment);
  166. X.sp
  167. X/*
  168. X    This code is like lower_bound2 but with files (for C)
  169. X*/
  170. Xvoid
  171. Xlower_bound(double bound, FILE * input_file, FILE * output_file, char *comment);
  172. X.fi
  173. X.SH "DESCRIPTION"
  174. XThis is a package of tools to do useful things with var files.
  175. XI make no claims about the completeness or consistency of this package.
  176. XIt is meant to be used with the var(3) routines and to be called
  177. Xeither from C or C++.
  178. XAt the moment it is considerably more
  179. Xconvinient to use from C++ with the image(5) package.
  180. XThe routines are as shown below, routines that end with 2 are meant
  181. Xonly to be called from C++ with the image(5) package.
  182. X.IP "iff2var"
  183. XThis is a routine written in C that takes 2 file pointers and
  184. Xretrieves a valid iff file from the first and sends a valid var file
  185. Xwith the same information into the second.
  186. XAny annotation in the
  187. Xiff file is lost.
  188. X.IP "var2iff"
  189. XThis is the inverse operation to iff2var.
  190. XIt reads a varfile
  191. Xand writes an iff file.
  192. XAny comments in the varfile are lost.
  193. XIt is also written in C.
  194. X.IP "ascii2var"
  195. XThis reads in a file in an ascii format.
  196. XThe ascii format is
  197. Xto have the first two things in the file be the length and width
  198. Xof the image.
  199. XThen each pixel of the image is read in as the
  200. Xascii representation of a floating point number.
  201. XAftern a sufficient
  202. Xnumber of numbers are read in the rest of the file is considerred to
  203. Xbe comments.
  204. XThis ascii format is convinient when constructing templates
  205. Xor transfering data between machines with different floating point formats.
  206. X.IP "var2ascii"
  207. XThis is the inverse operation of ascii2var, reading in a var file
  208. Xand writing out an ascii file using a supplied format string to 
  209. Xformat the floating point numbers being output.
  210. X.IP "var2ascii2"
  211. XThis command is the same as var2ascii except instead of being given
  212. Xa file to work on it takes an image data structure (which may be
  213. Xconstructed rather than read in from a file).
  214. X.IP "trunc2"
  215. XThis command takes in a double image data structure and truncates
  216. Xeach of the floating point pixels into and integral pixel.
  217. XIt outputs
  218. Xa graytone image data structure.
  219. X.IP "trunc"
  220. XThis is the version that works with files instead of data structures.
  221. X.IP "scale2"
  222. XThis routine takes every pixel of an input data structures, multiplies
  223. Xit by a scaling constant and increments it with an incrementation
  224. Xconstant.
  225. XThe combination scale2 trunc2 and var2iff are supposed to
  226. Xbe particularly useful for displaying var files.
  227. X.IP "scale"
  228. XThis is like scale2 but with files instead of data structures.
  229. X.IP "correlate2"
  230. XThis correlates an image with a template.
  231. XBoth are entered as 
  232. Xdouble image data structures.
  233. XThe output only contains the points
  234. Xwhere the template did not fall off the edge.
  235. X.IP "correlate"
  236. XThis is the version of correlate2 with files instead of data structures.
  237. X.IP "lower_bound2"
  238. XThis routine goes through the pixels of a var image and sets any that
  239. Xgo below the bound to the bound.
  240. XIt is meant to limit the range of
  241. Xvalues of the pixels for inspection or error control.
  242. X.IP "lower_bound"
  243. XThis is like lowerbound2 but with files instead of image data structures.
  244. X.IP "upper_bound2"
  245. XThis routine goes through the pixels of a var image and sets any
  246. Xthat exceed the bound to the bound.
  247. XIt is meant to limit the range of
  248. Xvalues of the pixels for inspection or error control.
  249. X.IP "upper_bound"
  250. XThis is like upper_bound2 but with files instead of image data structures.
  251. X.SH "FILES"
  252. X/usr/local/include/vartools.h
  253. X/usr/local/include/vartools.h++
  254. X.SH "SEE ALSO"
  255. Xvar(3) var(5) image(5)
  256. X.SH "DIAGNOSTICS"
  257. XWhen something goes wrong in general it will print an error message
  258. Xand dump core.
  259. X.SH "BUGS"
  260. XProbably.
  261. @//E*O*F man/vartools.3//
  262. chmod u=rw,g=r,o=r $OUT
  263.  
  264. echo x - man/var2ascii.1
  265. if test -f man/var2ascii.1 ; then
  266.     echo man/var2ascii.1 exists, putting output in $$man/var2ascii.1
  267.     OUT=$$man/var2ascii.1
  268.     STATUS=1
  269. else
  270.     OUT=man/var2ascii.1
  271. fi
  272. sed 's/^X//' > $OUT <<'@//E*O*F man/var2ascii.1//'
  273. X.TH VAR2ASCII 1 8/25/86
  274. X.CM 1
  275. X.SH "NAME"
  276. Xvar2ascii \- takes a var file and outputs it in ascii format
  277. X.SH "SYNOPSIS"
  278. Xvar2ascii [format [input.var [output.ascii]]]
  279. X.SH "DESCRIPTION"
  280. XThis program is designed to output in ascii format a double precision
  281. Xvar file (though since graytone is automatically converted to double
  282. Xit can also handle graytone).
  283. XThe output is 2 dimensions followed by
  284. Xthe pixels in row order followed by the comments.
  285. XThe first argument
  286. Xis the format string used to print out the strings.
  287. XIf it is left
  288. Xout var2ascii must be used as a pipe and it uses a default format.
  289. XIf only the format is given var2ascii is a pipe.
  290. XOtherwise giving
  291. Xthe input file only with output to stdout.
  292. XOtherwise the behavior
  293. Xis as one would expect.
  294. XThis program can facilitate passing floating point images
  295. Xbetween machines with incompatible floating point formats.
  296. X.SH "SEE ALSO"
  297. Xvar(3) var(5) vartools(3) ascii2var(1)
  298. X.SH "DIAGNOSTICS"
  299. Xprints error message and dumps core 
  300. X.SH "BUGS"
  301. XHmmmm....
  302. X,
  303. @//E*O*F man/var2ascii.1//
  304. chmod u=rw,g=r,o=r $OUT
  305.  
  306. echo x - man/truncate.1
  307. if test -f man/truncate.1 ; then
  308.     echo man/truncate.1 exists, putting output in $$man/truncate.1
  309.     OUT=$$man/truncate.1
  310.     STATUS=1
  311. else
  312.     OUT=man/truncate.1
  313. fi
  314. sed 's/^X//' > $OUT <<'@//E*O*F man/truncate.1//'
  315. X.TH TRUNCATE 1 8/25/86
  316. X.CM 1
  317. X.SH "NAME"
  318. Xtruncate \- takes a floating point image and generates a graytone image
  319. X.SH "SYNOPSIS"
  320. Xtruncate [input.var [output.var]]
  321. X.SH "DESCRIPTION"
  322. XThis takes a floating point var file and generates a graytone
  323. Xvar file by truncating the pixels.
  324. XIf no arguments then its a pipe.
  325. XIf only input is given output to stdout.
  326. XOtherwise input
  327. Xand output is specified.
  328. XThis routine can be useful in turning a floating point image into
  329. Xan image displayed on a screen.
  330. X.SH "SEE ALSO"
  331. Xvar(5) var(3) vartools(3)
  332. X.SH "DIAGNOSTICS"
  333. Xprints errors and dumps core.
  334. X.SH "BUGS"
  335. XHmmm...
  336. @//E*O*F man/truncate.1//
  337. chmod u=rw,g=r,o=r $OUT
  338.  
  339. echo x - man/scale.1
  340. if test -f man/scale.1 ; then
  341.     echo man/scale.1 exists, putting output in $$man/scale.1
  342.     OUT=$$man/scale.1
  343.     STATUS=1
  344. else
  345.     OUT=man/scale.1
  346. fi
  347. sed 's/^X//' > $OUT <<'@//E*O*F man/scale.1//'
  348. X.TH SCALE 1 8/25/86
  349. X.CM 1
  350. X.SH "NAME"
  351. Xscale \- scales and increments pixels of an image.
  352. X.SH "SYNOPSIS"
  353. Xscale scale [increment [input.var [output.var]]]
  354. X.SH "DESCRIPTION"
  355. XThis program multiplies every pixel of a floating point image
  356. Xby a scale (specified in the first argument) and adds to them
  357. Xan increment (specified in the second argument).
  358. XIf the second
  359. Xargument is left out the increment is set to 0 and the program
  360. Xacts as a pipe.
  361. XOtherwise the 3rd argument when present specifies
  362. Xthe input file and the 4th argument when present specifies the
  363. Xoutput file.
  364. XIf the 3rd or 4th argument are left out then the 
  365. Xprogram suplies stdin and stdout for the missing arguments.
  366. X.SH "SEE ALSO"
  367. Xvar(3) var(5) vartools(3)
  368. X.SH "DIAGNOSTICS"
  369. Xprints error message and dumps core
  370. X.SH "BUGS"
  371. XHmmm....
  372. @//E*O*F man/scale.1//
  373. chmod u=rw,g=r,o=r $OUT
  374.  
  375. echo x - man/correlate.1
  376. if test -f man/correlate.1 ; then
  377.     echo man/correlate.1 exists, putting output in $$man/correlate.1
  378.     OUT=$$man/correlate.1
  379.     STATUS=1
  380. else
  381.     OUT=man/correlate.1
  382. fi
  383. sed 's/^X//' > $OUT <<'@//E*O*F man/correlate.1//'
  384. X.TH CORRELATE 1 8/25/86
  385. X.CM 1
  386. X.SH "NAME"
  387. Xcorrelate \- correlates an input image with a template
  388. X.SH "SYNOPSIS"
  389. Xcorrelate template.var [input.var [output.var]]
  390. X.SH "DESCRIPTION"
  391. XThis generates the correlation of a template with an input file.
  392. XIt only generates points when the template fits entirely within the
  393. Xinput image so the output is smaller than the input.
  394. XWhen the input
  395. Xand output files are not supplied they are replaced by stdin and stdout.
  396. X.SH "SEE ALSO"
  397. Xvar(3) vartools(3) var(5)
  398. X.SH "DIAGNOSTICS"
  399. Xprints error message and dumps core
  400. X.SH "BUGS"
  401. XHmmm....
  402. @//E*O*F man/correlate.1//
  403. chmod u=rw,g=r,o=r $OUT
  404.  
  405. echo x - man/lowerbound.1
  406. if test -f man/lowerbound.1 ; then
  407.     echo man/lowerbound.1 exists, putting output in $$man/lowerbound.1
  408.     OUT=$$man/lowerbound.1
  409.     STATUS=1
  410. else
  411.     OUT=man/lowerbound.1
  412. fi
  413. sed 's/^X//' > $OUT <<'@//E*O*F man/lowerbound.1//'
  414. X.TH LOWERBOUND 1 8/25/86
  415. X.CM 1
  416. X.SH "NAME"
  417. Xlowerbound \- places a lower bound on the pixels of a var file
  418. X.SH "SYNOPSIS"
  419. Xlowerbound bound [input.var [output.var]]
  420. X.SH "DESCRIPTION"
  421. XThis goes through the pixels of a var file and all the ones
  422. Xthat are less than the bound are set to the bound.
  423. XIf input or output are not supplied they are replaced with stdin
  424. Xand stdout
  425. X.SH "SEE ALSO"
  426. Xvar(3) var(5) vartools(3) upperbound(1)
  427. X.SH "DIAGNOSTICS"
  428. Xprints error messages and dumps core for the most part.
  429. X.SH "BUGS"
  430. XHmmm....
  431. @//E*O*F man/lowerbound.1//
  432. chmod u=rw,g=r,o=r $OUT
  433.  
  434. echo x - man/upperbound.1
  435. if test -f man/upperbound.1 ; then
  436.     echo man/upperbound.1 exists, putting output in $$man/upperbound.1
  437.     OUT=$$man/upperbound.1
  438.     STATUS=1
  439. else
  440.     OUT=man/upperbound.1
  441. fi
  442. sed 's/^X//' > $OUT <<'@//E*O*F man/upperbound.1//'
  443. X.TH UPPERBOUND 1 8/25/86
  444. X.CM 1
  445. X.SH "NAME"
  446. Xupperbound \- places an upperbound on the pixels of a var file
  447. X.SH "SYNOPSIS"
  448. Xupperbound bound [input.var [output.var]]
  449. X.SH "DESCRIPTION"
  450. XThis program goes through the pixels of a var file replacing
  451. Xeach pixel that exceeds the bound with the bound.
  452. XThis program should be useful in constructing files to be
  453. Xshown on devices with limited range.
  454. XWhen input or output file names are not present they are replaced
  455. Xwith stdin and stdout respectively.
  456. X.SH "SEE ALSO"
  457. Xvar(3) var(5) vartools(3) lowerbound(1)
  458. X.SH "DIAGNOSTICS"
  459. Xprints error message and dumps core for the most part
  460. X.SH "BUGS"
  461. XHmmm....
  462. @//E*O*F man/upperbound.1//
  463. chmod u=rw,g=r,o=r $OUT
  464.  
  465. echo x - scale/main.c++
  466. if test -f scale/main.c++ ; then
  467.     echo scale/main.c++ exists, putting output in $$scale/main.c++
  468.     OUT=$$scale/main.c++
  469.     STATUS=1
  470. else
  471.     OUT=scale/main.c++
  472. fi
  473. sed 's/^X//' > $OUT <<'@//E*O*F scale/main.c++//'
  474. X/*
  475. X    Main routine for scaling image
  476. X    Syntax of scale is:
  477. X    scale scale [increment [input.var [output.var]]]
  478. X*/
  479.  
  480. X#include <stream.h>
  481. X#include <stdio.h>
  482. X#include <string.h>
  483. X#include <vartools.h++>
  484.  
  485. Xint
  486. Xmain ( int argc , char *argv[] )
  487. X    {
  488. X    switch(argc)
  489. X    {
  490. X    // if just scale given (acts as a pipe)
  491. X    case 2:
  492. X    scale(atof(argv[1]),0.,stdin,stdout,"");
  493. X    break;
  494. X    // if just scale and increment given (acts as a pipe)
  495. X    case 3:
  496. X    scale(atof(argv[1]),atof(argv[2]),stdin,stdout,"");
  497. X    break;
  498. X    // if scale, increment and input file given (output to stdout)
  499. X    case 4:
  500. X        {
  501. X        FILE *input;
  502. X        if(NULL == (input = fopen(argv[3],"r")))
  503. X        {
  504. X        char * string = form("Could not open %s for reading:",argv[3]);
  505. X        perror(string);
  506. X        return 2;
  507. X        }
  508. X        scale(atof(argv[1]),atof(argv[2]),input,stdout,"");
  509. X        }
  510. X    break;
  511. X    // if scale, increment, input file and output file given
  512. X    case 5:
  513. X        {
  514. X        FILE *input;
  515. X        FILE *output;
  516. X        if(NULL == (input = fopen(argv[3],"r")))
  517. X        {
  518. X        char * string = form("Could not open %s for reading:",argv[3]);
  519. X        perror(string);
  520. X        return 2;
  521. X        }
  522. X        if(NULL == (output = fopen(argv[4],"w")))
  523. X        {
  524. X        char * string = form("Could not open %s for writing:",argv[3]);
  525. X        perror(string);
  526. X        return 3;
  527. X        }
  528. X        scale(atof(argv[1]),atof(argv[2]),input,output,"");
  529. X        }
  530. X    break;
  531. X    // if wrong arguments given
  532. X    default:
  533. X    cerr << "Syntax is: scale scale [increment [input.var [output.var]]]\n";
  534. X    return 1;
  535. X    break;
  536. X    }
  537. X    
  538. X    return 0;
  539. X    }
  540.  
  541. X/*
  542. XCopyright (C) 1986, David Sher in the University of Rochester
  543. XPermission is granted to any individual or institution to use, copy, or
  544. Xredistribute this software so long as it is not sold for profit, provided
  545. Xthis copyright notice is retained.
  546. X*/
  547. @//E*O*F scale/main.c++//
  548. chmod u=rw,g=r,o=r $OUT
  549.  
  550. echo x - scale/makefile
  551. if test -f scale/makefile ; then
  552.     echo scale/makefile exists, putting output in $$scale/makefile
  553.     OUT=$$scale/makefile
  554.     STATUS=1
  555. else
  556.     OUT=scale/makefile
  557. fi
  558. sed 's/^X//' > $OUT <<'@//E*O*F scale/makefile//'
  559. X# this is the makefile for iff2var
  560.  
  561. X.SUFFIXES: .c++ 
  562.  
  563. X# This line constructs the program name (equal to the directory name)
  564. X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[
  565. XPROGRAM = scale
  566.  
  567. XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug 
  568.  
  569.  
  570. XC++FLAGS = +i $(CFLAGS)
  571.  
  572. XLIBS = -lvartools -lvarc++ -lvar -liff 
  573.  
  574. X# This line constructs the list of possible objects
  575. X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M
  576. XOBJS = \
  577. X    main.o 
  578.  
  579.  
  580. X.c++.o:
  581. X    c++ -c  $(C++FLAGS) $*.c++ 
  582.  
  583. X# the program is linked by this line
  584. X$(PROGRAM) : $(OBJS)
  585. X    c++ -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) 
  586.  
  587. X# the program is linted by this line
  588. X$(PROGRAM).lint : *.c 
  589. X    lint -hb *.c -lm > lint.out
  590. @//E*O*F scale/makefile//
  591. chmod u=rw,g=r,o=r $OUT
  592.  
  593. echo x - truncate/main.c++
  594. if test -f truncate/main.c++ ; then
  595.     echo truncate/main.c++ exists, putting output in $$truncate/main.c++
  596.     OUT=$$truncate/main.c++
  597.     STATUS=1
  598. else
  599.     OUT=truncate/main.c++
  600. fi
  601. sed 's/^X//' > $OUT <<'@//E*O*F truncate/main.c++//'
  602. X/*
  603. X    Main routine for calling the trunc routine
  604. X*/
  605.  
  606. X#include <stream.h>
  607. X#include <stdio.h>
  608. X#include <vartools.h++>
  609.  
  610. Xint
  611. Xmain ( int argc , char *argv[] )
  612. X    {
  613. X    switch(argc)
  614. X    {
  615. X    // with no arguments it acts as a pipe
  616. X    case 1:
  617. X    trunc(stdin,stdout,"Truncating file from stdin\n");
  618. X    break;
  619. X    // with 1 argument it reads from specified file and writes to stdout
  620. X    case 2:
  621. X    FILE *input;
  622. X    if(NULL == (input = fopen(argv[1],"r")))
  623. X        {
  624. X        perror("trunc:");
  625. X        return 5;
  626. X        }
  627. X    trunc(input,stdout,form("Truncating file %s\n",argv[1]));
  628. X    break;
  629. X    // with 2 arguments it reads from specified file and writes to 
  630. X    // specified file
  631. X    case 3:
  632. X    FILE *input;
  633. X    FILE *output;
  634. X    if(NULL == (input = fopen(argv[1],"r")))
  635. X        {
  636. X        perror("trunc:");
  637. X        return 5;
  638. X        }
  639. X    if(NULL == (output = fopen(argv[2],"w")))
  640. X        {
  641. X        perror("trunc:");
  642. X        return 6;
  643. X        }
  644. X    trunc(input,output,form("Truncating file %s to file %s\n",argv[1],argv[2]));
  645. X    break;
  646. X    // otherwise wrong number of arguments failure!
  647. X    default:
  648. X    cerr << "Syntax is: trunc [input.var [output.var]]";
  649. X    return 1;
  650. X    break;
  651. X    }
  652. X    return 0;
  653. X    }
  654. X/*
  655. XCopyright (C) 1986, David Sher in the University of Rochester
  656. XPermission is granted to any individual or institution to use, copy, or
  657. Xredistribute this software so long as it is not sold for profit, provided
  658. Xthis copyright notice is retained.
  659. X*/
  660. @//E*O*F truncate/main.c++//
  661. chmod u=rw,g=r,o=r $OUT
  662.  
  663. echo x - truncate/makefile
  664. if test -f truncate/makefile ; then
  665.     echo truncate/makefile exists, putting output in $$truncate/makefile
  666.     OUT=$$truncate/makefile
  667.     STATUS=1
  668. else
  669.     OUT=truncate/makefile
  670. fi
  671. sed 's/^X//' > $OUT <<'@//E*O*F truncate/makefile//'
  672. X# this is the makefile for iff2var
  673.  
  674. X.SUFFIXES: .c++ 
  675.  
  676. X# This line constructs the program name (equal to the directory name)
  677. X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[
  678. XPROGRAM = truncate
  679.  
  680. XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug 
  681.  
  682.  
  683. XC++FLAGS = +i $(CFLAGS)
  684.  
  685. XLIBS = -lvartools -lvarc++ -lvar -liff 
  686.  
  687. X# This line constructs the list of possible objects
  688. X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M
  689. XOBJS = \
  690. X    main.o 
  691.  
  692.  
  693. X.c++.o:
  694. X    c++ -c  $(C++FLAGS) $*.c++ 
  695.  
  696. X# the program is linked by this line
  697. X$(PROGRAM) : $(OBJS)
  698. X    c++ -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) 
  699.  
  700. X# the program is linted by this line
  701. X$(PROGRAM).lint : *.c 
  702. X    lint -hb *.c -lm > lint.out
  703. @//E*O*F truncate/makefile//
  704. chmod u=rw,g=r,o=r $OUT
  705.  
  706. echo x - upperbound/main.c++
  707. if test -f upperbound/main.c++ ; then
  708.     echo upperbound/main.c++ exists, putting output in $$upperbound/main.c++
  709.     OUT=$$upperbound/main.c++
  710.     STATUS=1
  711. else
  712.     OUT=upperbound/main.c++
  713. fi
  714. sed 's/^X//' > $OUT <<'@//E*O*F upperbound/main.c++//'
  715. X/*
  716. X    This applies an upper bound to a var file
  717. X    The syntax is:
  718. X    upperbound bound [input.var [output.var]]
  719. X*/
  720. X#include <stream.h>
  721. X#include <stdio.h>
  722. X#include <vartools.h++>
  723.  
  724.  
  725. Xint
  726. Xmain ( int argc , char *argv[] )
  727. X    {
  728. X    switch(argc)
  729. X    {
  730. X    // with 1 argument it acts as a pipe
  731. X    case 2:
  732. X    upper_bound(atof(argv[1]),stdin,stdout,"Bounding file from stdin\n");
  733. X    break;
  734. X    // with 2 arguments it reads from specified file and writes to stdout
  735. X    case 3:
  736. X    FILE *input;
  737. X    if(NULL == (input = fopen(argv[2],"r")))
  738. X        {
  739. X        perror(form("upperbound problem with openning %s:",argv[2]));
  740. X        return 5;
  741. X        }
  742. X    upper_bound(atof(argv[1]),input,stdout,form("bounding file %s\n",argv[2]));
  743. X    break;
  744. X    // with 3 arguments it reads from specified file and writes to 
  745. X    // specified file
  746. X    case 4:
  747. X    FILE *input;
  748. X    FILE *output;
  749. X    if(NULL == (input = fopen(argv[2],"r")))
  750. X        {
  751. X        perror(form("upperbound problem with openning %s:",argv[2]));
  752. X        return 5;
  753. X        }
  754. X    if(NULL == (output = fopen(argv[3],"w")))
  755. X        {
  756. X        perror(form("upperbound problem with openning %s:",argv[3]));
  757. X        return 6;
  758. X        }
  759. X    upper_bound(atof(argv[1]),input,output,form("bounding file %s to file %s\n",argv[2],argv[3]));
  760. X    break;
  761. X    // otherwise wrong number of arguments failure!
  762. X    default:
  763. X    cerr << "Syntax is: upperbound bound [input.var [output.var]]";
  764. X    return 1;
  765. X    break;
  766. X    }
  767. X    return 0;
  768. X    }
  769. X/*
  770. XCopyright (C) 1986, David Sher in the University of Rochester
  771. XPermission is granted to any individual or institution to use, copy, or
  772. Xredistribute this software so long as it is not sold for profit, provided
  773. Xthis copyright notice is retained.
  774. X*/
  775. @//E*O*F upperbound/main.c++//
  776. chmod u=rw,g=r,o=r $OUT
  777.  
  778. echo x - upperbound/makefile
  779. if test -f upperbound/makefile ; then
  780.     echo upperbound/makefile exists, putting output in $$upperbound/makefile
  781.     OUT=$$upperbound/makefile
  782.     STATUS=1
  783. else
  784.     OUT=upperbound/makefile
  785. fi
  786. sed 's/^X//' > $OUT <<'@//E*O*F upperbound/makefile//'
  787. X# this is the makefile for iff2var
  788.  
  789. X.SUFFIXES: .c++ 
  790.  
  791. X# This line constructs the program name (equal to the directory name)
  792. X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[
  793. XPROGRAM = upperbound
  794.  
  795. XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug 
  796.  
  797.  
  798. XC++FLAGS = +i $(CFLAGS)
  799.  
  800. XLIBS = -lvartools -lvarc++ -lvar -liff 
  801.  
  802. X# This line constructs the list of possible objects
  803. X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M
  804. XOBJS = \
  805. X    main.o 
  806.  
  807.  
  808. X.c++.o:
  809. X    c++ -c  $(C++FLAGS) $*.c++ 
  810.  
  811. X# the program is linked by this line
  812. X$(PROGRAM) : $(OBJS)
  813. X    c++ -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) 
  814.  
  815. X# the program is linted by this line
  816. X$(PROGRAM).lint : *.c 
  817. X    lint -hb *.c -lm > lint.out
  818. @//E*O*F upperbound/makefile//
  819. chmod u=rw,g=r,o=r $OUT
  820.  
  821. echo x - var2ascii/main.c++
  822. if test -f var2ascii/main.c++ ; then
  823.     echo var2ascii/main.c++ exists, putting output in $$var2ascii/main.c++
  824.     OUT=$$var2ascii/main.c++
  825.     STATUS=1
  826. else
  827.     OUT=var2ascii/main.c++
  828. fi
  829. sed 's/^X//' > $OUT <<'@//E*O*F var2ascii/main.c++//'
  830. X/*
  831. X    This is the main routine for translating floating point images
  832. X    to ascii
  833. X*/
  834.  
  835. X#include <stream.h>
  836. X#include <stdio.h>
  837. X#include <vartools.h++>
  838.  
  839. Xint
  840. Xmain(int argc,char *argv[])
  841. X    {
  842. X    switch ( argc )
  843. X    {
  844. X    // with 0 arguments it is a pipe with default format
  845. X    case 1:
  846. X    var2ascii(stdin,stdout,"%lf ");
  847. X    break;
  848. X    // with 1 argument it is a pipe with entered format
  849. X    case 2:
  850. X    var2ascii(stdin,stdout,argv[1]);
  851. X    break;
  852. X    // with 2 arguments it takes from named file to stdout
  853. X    case 3:
  854. X    {
  855. X    FILE *input;    // pointer to the input file
  856. X    if ( NULL == ( input = fopen(argv[2],"r") ) )
  857. X        {
  858. X        perror("var2ascii");
  859. X        return 2;
  860. X        }
  861. X    var2ascii(input,stdout,argv[1]);
  862. X    }
  863. X    break;
  864. X    // with 3 arguments it takes from named file to named file
  865. X    case 4:
  866. X    {
  867. X    FILE *input;    // pointer to the input file
  868. X    FILE *output;    // pointer to the output file
  869. X    if ( NULL == ( input = fopen(argv[2],"r") ) )
  870. X        {
  871. X        perror("var2ascii");
  872. X        return 2;
  873. X        }
  874. X    if ( NULL == ( output = fopen(argv[3],"w") ) )
  875. X        {
  876. X        perror("var2ascii");
  877. X        return 2;
  878. X        }
  879. X    var2ascii(input,output,argv[1]);
  880. X    }
  881. X    break;
  882. X    // otherwise something is wrong
  883. X    default:
  884. X    cerr << "Syntax is: var2ascii [input [output]]\n";
  885. X    return 1;
  886. X    }
  887. X    return 0;
  888. X    }
  889. X/*
  890. XCopyright (C) 1986, David Sher in the University of Rochester
  891. XPermission is granted to any individual or institution to use, copy, or
  892. Xredistribute this software so long as it is not sold for profit, provided
  893. Xthis copyright notice is retained.
  894. X*/
  895. @//E*O*F var2ascii/main.c++//
  896. chmod u=rw,g=r,o=r $OUT
  897.  
  898. echo x - var2ascii/makefile
  899. if test -f var2ascii/makefile ; then
  900.     echo var2ascii/makefile exists, putting output in $$var2ascii/makefile
  901.     OUT=$$var2ascii/makefile
  902.     STATUS=1
  903. else
  904.     OUT=var2ascii/makefile
  905. fi
  906. sed 's/^X//' > $OUT <<'@//E*O*F var2ascii/makefile//'
  907. X# this is the makefile for iff2var
  908.  
  909. X.SUFFIXES: .c++ 
  910.  
  911. X# This line constructs the program name (equal to the directory name)
  912. X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[
  913. XPROGRAM = var2ascii
  914.  
  915. XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug 
  916.  
  917.  
  918. XC++FLAGS = +i $(CFLAGS)
  919.  
  920. XLIBS = -lvartools -lvarc++ -lvar -liff 
  921.  
  922. X# This line constructs the list of possible objects
  923. X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M
  924. XOBJS = \
  925. X    main.o 
  926.  
  927.  
  928. X.c++.o:
  929. X    c++ -c  $(C++FLAGS) $*.c++ 
  930.  
  931. X# the program is linked by this line
  932. X$(PROGRAM) : $(OBJS)
  933. X    c++ -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) 
  934.  
  935. X# the program is linted by this line
  936. X$(PROGRAM).lint : *.c 
  937. X    lint -hb *.c -lm > lint.out
  938. @//E*O*F var2ascii/makefile//
  939. chmod u=rw,g=r,o=r $OUT
  940.  
  941. echo x - varc++/archive.h++
  942. if test -f varc++/archive.h++ ; then
  943.     echo varc++/archive.h++ exists, putting output in $$varc++/archive.h++
  944.     OUT=$$varc++/archive.h++
  945.     STATUS=1
  946. else
  947.     OUT=varc++/archive.h++
  948. fi
  949. sed 's/^X//' > $OUT <<'@//E*O*F varc++/archive.h++//'
  950. X/*
  951. X    This file contains definitions for archive manipulation routines
  952. X*/
  953. X/*
  954. X    Archive format definitions
  955. X*/
  956. X#include "ar.h"
  957.  
  958. X/*
  959. XGeneral Utility
  960. X*/
  961. X/*
  962. XReads in a certain number of bytes from a file or fail with message
  963. Xto stderr.  If at EOF returns a NULL pointer.  
  964. X*/
  965. Xchar *
  966. Xar_read_bytes_from_file_or_report_eof(const int file_descriptor , const int number_bytes );
  967.  
  968. X/*
  969. XWrites out a certain number of bytes from a file or fail with message
  970. Xto stderr.  If at EOF returns a NULL pointer.  
  971. X*/
  972. Xvoid
  973. Xar_write_bytes_to_file_or_report_error( int file_descriptor , int buffer,  int number_bytes  );
  974.  
  975. X/*
  976. X    Routines to access archives
  977. X*/
  978. X/*
  979. X    Checks that the archive is valid
  980. X    returns 1 if valid 0 otherwise
  981. X    should be run at begining of file
  982. X*/
  983. Xchar
  984. Xar_check_archive(FILE  *fptr );
  985.  
  986. X/*
  987. X    Writes out the archive header to a file and checks for errors
  988. X*/
  989. Xvoid
  990. Xar_write_archive_header( FILE *archive_file );
  991.  
  992. X/*
  993. X    Reads in an archive header or reports that you are at eof
  994. X    by returning a NULL pointer.
  995. X*/
  996. Xstruct ar_hdr *
  997. Xar_read_header_or_report_eof(FILE *fptr );
  998.  
  999. X/*
  1000. X    Writes out the archive header for each file
  1001. X*/
  1002. Xvoid
  1003. Xar_write_header( FILE *archive_file, char *buffer, struct ar_hdr *header );
  1004.  
  1005. X/*
  1006. X    Reads a file into memory
  1007. X*/
  1008. Xchar *
  1009. Xar_read_file(FILE * fptr , struct ar_hdr *header);
  1010.  
  1011. X/*
  1012. X    writes the contents of a file out to an archive
  1013. X*/
  1014. Xvoid
  1015. Xar_write_file( FILE *archive_file, char *buffer, struct ar_hdr * header );
  1016.  
  1017. X/*
  1018. X    Creates a header for an archive entry
  1019. X*/
  1020. Xstruct ar_hdr *
  1021. Xar_create_header(const char * name , const int date , const int uid , const int gid , const int mode , const int size , const char * fmag );
  1022.  
  1023.  
  1024. X/*
  1025. X    Definitions of sizes for header elements
  1026. X*/
  1027. X#define AR_FILE_NAME_SIZE 16    /* the file name */
  1028. X#define AR_FILE_PROTECTION_SIZE 8    /* the file protection */
  1029. X#define AR_FILE_UID_SIZE 6    /* the file uid */
  1030. X#define AR_FILE_GID_SIZE 6    /* the file gid */
  1031. X#define AR_FILE_DATE_SIZE 12    /* the file date */
  1032. X#define AR_FILE_SIZE_SIZE 10    /* the file size */
  1033.  
  1034. X/*
  1035. X    Routines to access entries from the archive header
  1036. X*/
  1037.  
  1038. X/*
  1039. X    Get the file name
  1040. X*/
  1041. Xchar *
  1042. Xar_file_name( struct  ar_hdr *header );
  1043.  
  1044. X/*
  1045. X    Get the protection
  1046. X*/
  1047. Xchar *
  1048. Xar_file_protection( struct  ar_hdr *header );
  1049.  
  1050. X/*
  1051. X    Get the uid
  1052. X*/
  1053. Xchar *
  1054. Xar_file_uid( struct ar_hdr *header );
  1055.  
  1056. X/*
  1057. X    Get the gid
  1058. X*/
  1059. Xchar *
  1060. Xar_file_gid( struct ar_hdr *header );
  1061.  
  1062. X/*
  1063. X    Get the date
  1064. X*/
  1065. Xchar *
  1066. Xar_file_date( struct ar_hdr *header );
  1067.  
  1068. X/*
  1069. X    Get the size
  1070. X*/
  1071. Xchar *
  1072. Xar_file_size( struct ar_hdr *header );
  1073.  
  1074. X/*
  1075. XCopyright (C) 1986, David Sher in the University of Rochester
  1076. XPermission is granted to any individual or institution to use, copy, or
  1077. Xredistribute this software so long as it is not sold for profit, provided
  1078. Xthis copyright notice is retained.
  1079. X*/
  1080. @//E*O*F varc++/archive.h++//
  1081. chmod u=rw,g=r,o=r $OUT
  1082.  
  1083. echo x - varc++/bitio.h++
  1084. if test -f varc++/bitio.h++ ; then
  1085.     echo varc++/bitio.h++ exists, putting output in $$varc++/bitio.h++
  1086.     OUT=$$varc++/bitio.h++
  1087.     STATUS=1
  1088. else
  1089.     OUT=varc++/bitio.h++
  1090. fi
  1091. sed 's/^X//' > $OUT <<'@//E*O*F varc++/bitio.h++//'
  1092. X/* file:  bitio.h                            */
  1093.  
  1094. X/* BFILE: include file for bit stream I/O.                */
  1095. X/* Bitio provides the capabilities to access unix files as arbitrary    */
  1096. X/*  bit streams. I/O is buffered on both reading and writing.        */
  1097. X/* Read, write, and read/write access is defined.            */
  1098. X/* Bit streams of upto the width in bits of a long integer may be read    */
  1099. X/*  and written with each access.                    */
  1100. X/* CPU word and character boundaries are otherwise ignored.        */
  1101. X/* These routines are compatible with normal unix file access.        */
  1102.  
  1103. X/* Copyright (c) 1982,
  1104. X   W. S. Havens,
  1105. X   Laboratory for Computational Vision,
  1106. X   University of British Columbia
  1107. X*/
  1108.  
  1109. X/* Modifications:
  1110. X    original:                        WSH 82/5/20
  1111. X    added delayed filling of cache:            WSH 82/5/27
  1112. X    change block size:                    SJK 84/5/4
  1113. X*/
  1114.  
  1115. X#define        BBLKSZE    4096        /* # of bytes in bit cache    */
  1116. X#define        R    0        /* mode = read            */
  1117. X#define        W    1        /* mode = write            */
  1118. X#define        RW    2        /* mode = read/write        */
  1119. X#define        UBXBYTE    8        /* # of bits per byte        */
  1120. X#define        WRDSZE    UBXBYTE*sizeof(long)/* # of bits per long word    */
  1121. X#define        BEOF    001
  1122. X#define        BRDERR    002
  1123. X#define        BWRERR    004
  1124. X#define        BSKERR    010
  1125. X#define        NULL    0
  1126.  
  1127. X/* flags:
  1128. X  Bit    Indication
  1129. X  ---    ----------
  1130. X   1    EOF during last read.
  1131. X   2    read error occurred.
  1132. X   3    write error occurred.
  1133. X   4    seek error occurred.
  1134. X*/
  1135.  
  1136. Xstruct iff_bfile
  1137. X {int        file;            /* unix file descriptor        */
  1138. X  short        wpos;            /* location of bword in cache    */
  1139. X  short        bpos;            /* current low-order bit    */
  1140. X  short        nwrd;            /* # of bytes in cache        */
  1141. X  short        bmode;            /* access mode of file        */
  1142. X  short        flags;            /* EOF and ERROR flags        */
  1143. X  char        cache[BBLKSZE];        /* byte cache for stream        */    
  1144. X  };
  1145.  
  1146. Xunsigned long    bseek(...);
  1147. Xstruct iff_bfile        *bopen(...), *bdopen(...);
  1148. X           
  1149.  
  1150. X/* Notes:
  1151. X   ------
  1152. X1) Beware of the odd bits !!
  1153.  
  1154. X*/
  1155.  
  1156. X/* Macros */
  1157.  
  1158. X#define beof(bfp)    ((bfp)->flags & BEOF)
  1159. X#define berror(bfp)    ((bfp)->flags & (BRDERR | BWRERR | BSKERR))
  1160. X#define bget(bfp,n,signed)                        \
  1161. X  ((n)!=8 || (bfp)->bpos || (bfp)->wpos>=(bfp)->nwrd || (bfp)->bmode==W ?\
  1162. X    fbget(bfp,n,signed) :                         \
  1163. X      (signed) ?                            \
  1164. X    *(char *)((bfp)->cache+((bfp)->wpos++)) :            \
  1165. X    *(unsigned char *)((bfp)->cache+((bfp)->wpos++)) )
  1166.  
  1167. X#define bput(bfp,bits,n)                        \
  1168. X  ((n)!=8 || (bfp)->bpos || (bfp)->wpos>=BBLKSZE || (bfp)->bmode!=W ?    \
  1169. X    fbput(bfp,bits,n) :                        \
  1170. X    (*(char *)(bfp->cache+bfp->wpos++) = bits))
  1171.  
  1172.  
  1173. X/* end of file:  bitio.h */
  1174. X/*
  1175. XCopyright (C) 1986, David Sher in the University of Rochester
  1176. XPermission is granted to any individual or institution to use, copy, or
  1177. Xredistribute this software so long as it is not sold for profit, provided
  1178. Xthis copyright notice is retained.
  1179. X*/
  1180. @//E*O*F varc++/bitio.h++//
  1181. chmod u=rw,g=r,o=r $OUT
  1182.  
  1183. echo x - varc++/char_image.h++
  1184. if test -f varc++/char_image.h++ ; then
  1185.     echo varc++/char_image.h++ exists, putting output in $$varc++/char_image.h++
  1186.     OUT=$$varc++/char_image.h++
  1187.     STATUS=1
  1188. else
  1189.     OUT=varc++/char_image.h++
  1190. fi
  1191. sed 's/^X//' > $OUT <<'@//E*O*F varc++/char_image.h++//'
  1192. X/*
  1193. X    This file contains the definitions necessary to define an
  1194. X    image whose data is 8-bit
  1195. X*/
  1196.  
  1197. X#ifndef CHAR_IMAGE_H
  1198. X#define CHAR_IMAGE_H
  1199. X/* include the support for image data types */
  1200. X#include "image.h++"
  1201.  
  1202. X/*
  1203. X    the definition of the class to manage image structures
  1204. X*/
  1205. Xclass char_image : image_class 
  1206. X    {
  1207. X    char *image_buffer;    // buffer to hold image
  1208. X    char **image_rows;    // pointers to the rows of the image
  1209. X    char **window_rows;    // pointers to the rows of the window
  1210. X    /* functions for function pointers */
  1211.  
  1212. X    /* this version of next assumes the window has been initialized */
  1213. X    int initialized_next ();
  1214.  
  1215. X    /* this version of prev assumes the window has been initialized */
  1216. X    int initialized_prev ();
  1217.  
  1218. X    /* this version of next initializes the window */
  1219. X    int uninitialized_next ();
  1220.  
  1221. X    /* this version of prev initializes the window */
  1222. X    int uninitialized_prev ();
  1223.  
  1224. X    /* this version of next says that the operation is impossible */
  1225. X    int impossible_next ();
  1226.  
  1227. X    /* this version of prev says that the operation is impossible */
  1228. X    int impossible_prev ();
  1229.  
  1230. X    /* uninitialized version of get_w_e will just die */
  1231. X    char uninitialized_get_w_e ( const card i , const card j );
  1232.  
  1233. X    /* initialized version of get_w_e */
  1234. X    char initialized_get_w_e ( const card i , const card j );
  1235.  
  1236. X    /* uninitialized version of write_w_e will just die */
  1237. X    void uninitialized_write_w_e ( const card i , const card j , const char value );
  1238.  
  1239. X    /* initialized version of write_w_e */
  1240. X    void initialized_write_w_e ( const card i , const card j , const char value );
  1241.  
  1242. X    /*
  1243. X    the function to write to the specified element of a window.
  1244. X    it is a function pointer so that unitialized windows
  1245. X    or protected images don't get read from
  1246. X    */
  1247. X    char (* get_w_e_pointer )( const card i , const card j  );
  1248.  
  1249. X    /*
  1250. X    the function to write to the specified element of a window.
  1251. X    it is a function pointer so that unitialized windows
  1252. X    or protected images don't get read from
  1253. X    can not check argument because it will point to internal
  1254. X    elements
  1255. X    */
  1256. X    void (* write_w_e_pointer )( const card i , const card j , const char value  );
  1257.  
  1258. Xpublic:
  1259. X    /* constructors */
  1260. X    /* the constructor when the image is being read from a file */
  1261. X    char_image
  1262. X    ( 
  1263. X    const read_image_type rit ,     // marker that the image is being read
  1264. X    const FILE * image_file ,    // file for image
  1265. X    const card w_width = 1 ,    // window width
  1266. X    const card w_length = 1        // window length
  1267. X    );
  1268.  
  1269. X    /* the constructor when the image is built */
  1270. X    char_image
  1271. X    ( 
  1272. X    const create_image_type cit ,    // marker that the image is being created
  1273. X    const card n_rows ,         // the number of rows in the image
  1274. X    const card n_cols ,         // the number of collumns in the image
  1275. X    const FILE * image_file ,    // file for image
  1276. X    const card w_width = 1 ,    // window width
  1277. X    const card w_length = 1     // window length
  1278. X    );
  1279.  
  1280. X    /* destructor (who would want to destroy an image?) */
  1281. X    ~char_image ( ) { ; }
  1282.  
  1283. X    /* access routines for parts of data structure */
  1284. X    const card n_rows() { return number_rows ; }
  1285. X    const card n_cols() { return number_cols ; }
  1286. X    const image_prot the_prot() { return prot; }
  1287. X    const card c_length() { return comment_length ; }
  1288. X    const char *the_comments() { return comments ; }
  1289. X    const card the_collumn() { return collumn ; }
  1290. X    const card the_row() { return row ; }
  1291. X    const card the_width() { return window_width ; }
  1292. X    const card the_length() { return window_length ; }
  1293. X    const FILE * the_file() { return file ; }
  1294. X    const status image_init() { return image_status ; }
  1295. X    const status window_init() { return window_status ; }
  1296.  
  1297. X    /* access a pointer to a particular row */
  1298. X    const char * get_row( card row );
  1299.  
  1300. X    /* sets the comments */
  1301. X    void set_comments( char * string , const card length )
  1302. X    {
  1303. X    this->image_class::set_comments ( string , length );
  1304. X    }
  1305.  
  1306. X    /* adds a string to the comments */
  1307. X    void add_comment( char * string , const card length )
  1308. X    {
  1309. X    this->image_class::add_comment ( string , length );
  1310. X    }
  1311.  
  1312.  
  1313. X    /* real versions of virtual functions */
  1314. X    /* routine to write out the image to a file */
  1315. X    void write ( ) ;
  1316.  
  1317. X    /*
  1318. X    move in row n steps 
  1319. X    returns 1 when that motion is legal 0 otherwise
  1320. X    */
  1321. X    int move_collumn ( const int n ) ;
  1322.  
  1323. X    /*
  1324. X    move in collumn n steps
  1325. X    returns 1 when that motion is legal 0 otherwise
  1326. X    */
  1327. X    int move_row ( const int n ) ;
  1328.  
  1329. X    /*
  1330. X    move to specified row
  1331. X    */
  1332. X    void move_to_row ( const card n ) ;
  1333.  
  1334. X    /*
  1335. X    move to specified collumn
  1336. X    */
  1337. X    void move_to_collumn ( const card n ) ;
  1338.  
  1339. X    
  1340. X    /*
  1341. X    the function to get the specified element of a window
  1342. X    it is a function pointer so that unitialized windows
  1343. X    or protected images don't get read from
  1344. X    this accesses the function pointer
  1345. X    */
  1346. X    char get_w_e ( const card i , const card j )
  1347. X    { return (( char (*) (...) )(* get_w_e_pointer)) ( this , i , j ); }
  1348.  
  1349. X    /*
  1350. X    the fast function without checking for initialization
  1351. X    of a function pointer for getting elements of a window
  1352. X    Also no bounds checking!
  1353. X    ( Not recommended!)
  1354. X    */
  1355. X    char fast_g_w_e ( const card i , const card j )
  1356. X    { return window_rows[i][j]; }
  1357. X    
  1358. X    /*
  1359. X    the function to write to the specified element of a window.
  1360. X    it is a function pointer so that unitialized windows
  1361. X    or protected images don't get read from
  1362. X    this accesses the function pointer
  1363. X    */
  1364. X    void write_w_e ( const card i , const card j , const char value )
  1365. X    { ((void (*) (...) )(* write_w_e_pointer)) ( this , i , j , value ); }
  1366.  
  1367. X    /*
  1368. X    the fast function without checking for initialization
  1369. X    of a function pointer for writing elements to a window
  1370. X    Also no bounds checking!
  1371. X    ( Not recommended!)
  1372. X    */
  1373. X    void fast_w_w_e ( const card i , const card j , const char value )
  1374. X    { window_rows[i][j] = value; }
  1375.  
  1376. X    /* 
  1377. X    the function call on the image gets the upper left hand 
  1378. X    of the image window and returns a reference so it can be
  1379. X    used as a lvalue or rvalue
  1380. X    optimized so does not check that the window is initialized
  1381. X    if the window is not initialized then odd things may happen
  1382. X    */
  1383. X    char& operator() ()
  1384. X    { return **window_rows; }
  1385. X    
  1386. X    /* 
  1387. X    move to next legal position in image
  1388. X    returns 1 when there is a next legal position 0 otherwise
  1389. X    if the window is not initialized then it initializes it.
  1390. X    with the window in the position 0,0 (if possible)
  1391. X    */
  1392. X    int (* next) (...); /* this will point to member functions! */
  1393.  
  1394. X    /* 
  1395. X    move to previous legal position in image
  1396. X    returns 1 when there is a previous legal position 0 otherwise
  1397. X    if the window is not initialized then it initializes it.
  1398. X    with the window in the farthest position (if possible)
  1399. X    */
  1400. X    int (* prev) (...); /* this will point to member functions! */
  1401.  
  1402. X    /*
  1403. X    Access for next and previous elements of images
  1404. X    */
  1405. X    int operator++ ( ) 
  1406. X    { return (* next) ( this /* because points to member*/ ); }
  1407. X    int operator-- ( ) 
  1408. X    { return (* prev) ( this /* because points to member*/ ); }
  1409.  
  1410. X    /*
  1411. X    Change the size of a window
  1412. X    causes the window to become uninitialized
  1413. X    */
  1414. X    void resize_window ( card width , card length );
  1415.  
  1416. X    /*
  1417. X    Causes the window to cover the entire image.
  1418. X    Allows one to access any part of the image with window operations
  1419. X    */
  1420. X    void window_entire_image ( );
  1421.  
  1422. X    };
  1423.  
  1424. X#endif CHAR_IMAGE_H
  1425. X/*
  1426. XCopyright (C) 1986, David Sher in the University of Rochester
  1427. XPermission is granted to any individual or institution to use, copy, or
  1428. Xredistribute this software so long as it is not sold for profit, provided
  1429. Xthis copyright notice is retained.
  1430. X*/
  1431. @//E*O*F varc++/char_image.h++//
  1432. chmod u=rw,g=r,o=r $OUT
  1433.  
  1434. echo x - varc++/error.h++
  1435. if test -f varc++/error.h++ ; then
  1436.     echo varc++/error.h++ exists, putting output in $$varc++/error.h++
  1437.     OUT=$$varc++/error.h++
  1438.     STATUS=1
  1439. else
  1440.     OUT=varc++/error.h++
  1441. fi
  1442. sed 's/^X//' > $OUT <<'@//E*O*F varc++/error.h++//'
  1443. X/*
  1444. X    This contains the definitions for the error handling routines 
  1445. X    I do not contain this file in my error handling routines so that
  1446. X    the extern definition of error_occured does not screw things up
  1447. X*/
  1448.  
  1449. X/*
  1450. X    flag that indicates an error occured
  1451. X*/
  1452. Xextern char error_occured;
  1453.  
  1454. X/*
  1455. X    Indicates an error occured and adds an error string to the
  1456. X    set of error strings
  1457. X*/
  1458. Xvoid
  1459. Xindicate_error(const char error_string[]);
  1460.  
  1461. X/*
  1462. X    Prints a set of error messages and aborts
  1463. X*/
  1464. Xvoid
  1465. Xprint_errors_and_abort();
  1466.  
  1467. X/*
  1468. X    Prints a set of error messages and exits with specified code
  1469. X*/
  1470. Xvoid
  1471. Xprint_errors_and_exit( const int exit_code);
  1472.  
  1473. X/*
  1474. X    Returns a system error string (to replace perror
  1475. X*/
  1476. Xconst char *
  1477. Xsystem_error_string();
  1478. X/*
  1479. XCopyright (C) 1986, David Sher in the University of Rochester
  1480. XPermission is granted to any individual or institution to use, copy, or
  1481. Xredistribute this software so long as it is not sold for profit, provided
  1482. Xthis copyright notice is retained.
  1483. X*/
  1484. @//E*O*F varc++/error.h++//
  1485. chmod u=rw,g=r,o=r $OUT
  1486.  
  1487. echo Inspecting for damage in transit...
  1488. temp=/tmp/sharin$$; dtemp=/tmp/sharout$$
  1489. trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
  1490. cat > $temp <<\!!!
  1491.      220    1228    7405 vartools.3
  1492.       30     164     996 var2ascii.1
  1493.       21      99     597 truncate.1
  1494.       24     132     787 scale.1
  1495.       18      90     566 correlate.1
  1496.       17      89     516 lowerbound.1
  1497.       19     103     635 upperbound.1
  1498.       73     227    1735 main.c++
  1499.       31     102     668 makefile
  1500.       58     186    1370 main.c++
  1501.       31     102     671 makefile
  1502.       60     208    1630 main.c++
  1503.       31     102     673 makefile
  1504.       65     226    1496 main.c++
  1505.       31     102     672 makefile
  1506.      130     448    2750 archive.h++
  1507.       88     405    2632 bitio.h++
  1508.      239    1271    7498 char_image.h++
  1509.       41     152     979 error.h++
  1510.     1227    5436   34276 total
  1511. !!!
  1512. wc  man/vartools.3 man/var2ascii.1 man/truncate.1 man/scale.1 man/correlate.1 man/lowerbound.1 man/upperbound.1 scale/main.c++ scale/makefile truncate/main.c++ truncate/makefile upperbound/main.c++ upperbound/makefile var2ascii/main.c++ var2ascii/makefile varc++/archive.h++ varc++/bitio.h++ varc++/char_image.h++ varc++/error.h++ | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
  1513. if test -s $dtemp ; then
  1514.     echo "Ouch [diff of wc output]:"
  1515.     cat $dtemp
  1516.     STATUS=1
  1517. elif test $STATUS = 0 ; then
  1518.     echo "No problems found."
  1519. else
  1520.     echo "WARNING -- PROBLEMS WERE FOUND..."
  1521. fi
  1522. exit $STATUS
  1523.